package de.boldt.java.log.util.log;

import java.io.OutputStream;
import java.io.PrintStream;

public class Log
{
	private static int size = 0;
	private boolean aktiv = false;
	private PrintStream stream;
	private OutputStream output;
	
	public Log()
	{
		this.output = System.out;
	}
	
	public Log(OutputStream output)
	{
		this.output = output;
	}
	
	public void logMessage(String s)
	{
		if(aktiv)
		{
			stream.println(s);
		}
	}
	
	public void setActiv(boolean status)
	{
		if(status)
		{
			stream = new PrintStream(this.output);
			System.setOut(stream);
			aktiv = true;
			size++;
		}
		else
		{
			stream = null;
			aktiv = false;
			size--;
		}
	}
	
	public boolean isAktiv()
	{
		return aktiv;
	}

	public static boolean isExistLog()
	{
		if(size > 0)
		{
			return true;
		}
		return false;
	}
	
	public void setOutputStream(OutputStream output)
	{
		this.output = output;
	}
	
	public OutputStream getOutputStream()
	{
		return this.output;
	}
}